<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/StaffTemplate.xhtml">

    <ui:define name="nav_menu">
        <p:menubar model="#{staffChangeInitialPasswordManagedBean.staffMenuModel}"/>
    </ui:define>
    <ui:define name="content">    
        <f:view beforePhase="#{tCubeULPManagerBean.initULPItemApplicationList}"></f:view>
        <p:panel header="View ULPItem Applications (Double click to select)">
            <p:accordionPanel autoHeight="false">
                <p:tab title="Pending Applications">
                    <p:dataTable var="pendingApplication" value="#{tCubeULPManagerBean.pendingULPItemApplicationList}" paginator="true" 
                                 rows="10" emptyMessage="No pending application" selection="#{tCubeULPManagerBean.selectedULPItemApplication}" 
                                 selectionMode="single" rowSelectListener="#{tCubeULPManagerBean.onRowNavigateULPItemApplication}"
                                 dblClickSelect="true">
                        <p:column sortBy="#{pendingApplication.id}" filterBy="#{pendingApplication.id}">
                            <f:facet name="header">
                                <h:outputText value="ID" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.id}" />
                        </p:column>

                        <p:column sortBy="#{pendingApplication.stakeholder.corpName}" filterBy="#{pendingApplication.stakeholder.corpName}">
                            <f:facet name="header">
                                <h:outputText value="Company name" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.stakeholder.corpName}" />
                        </p:column>

                        <p:column sortBy="#{pendingApplication.name}" filterBy="#{pendingApplication.name}">
                            <f:facet name="header">
                                <h:outputText value="Name" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.name}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Image" />
                            </f:facet>
                            <p:graphicImage id="imageDisplay" value="/images/upload/media/#{pendingApplication.imageURL}"
                                            height="50" width="70"/> 
                        </p:column>  

                        <p:column sortBy="#{pendingApplication.costOfItem}" filterBy="#{pendingApplication.costOfItem}">
                            <f:facet name="header">
                                <h:outputText value="Cost of item" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.costOfItem} SGD" />
                        </p:column>

                        <p:column sortBy="#{pendingApplication.maxQuantity}" filterBy="#{pendingApplication.maxQuantity}">
                            <f:facet name="header">
                                <h:outputText value="Maximum Quantity" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.maxQuantity}" />
                        </p:column>

                        <p:column sortBy="#{pendingApplication.validFrom}" filterBy="#{pendingApplication.validFrom}">
                            <f:facet name="header">
                                <h:outputText value="Valid From" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.validFrom}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{pendingApplication.validUntil}" filterBy="#{pendingApplication.validUntil}">
                            <f:facet name="header">
                                <h:outputText value="Valid Until" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.validUntil}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{pendingApplication.status}" filterBy="#{pendingApplication.status}">
                            <f:facet name="header">
                                <h:outputText value="Status" />
                            </f:facet>
                            <h:outputText value="#{pendingApplication.status}" />
                        </p:column>

                    </p:dataTable>
                </p:tab>

                <p:tab title="All ULPItem applications">
                    <p:dataTable var="ULPItemApplication" value="#{tCubeULPManagerBean.ULPItemApplicationList}" paginator="true" 
                                 rows="10" emptyMessage="No pending application" selection="#{tCubeULPManagerBean.selectedULPItemApplication}" 
                                 selectionMode="single" rowSelectListener="#{tCubeULPManagerBean.onRowSelectNavigateULPItemApplication}"
                                 dblClickSelect="true">

                        <p:column sortBy="#{ULPItemApplication.id}" filterBy="#{ULPItemApplication.id}">
                            <f:facet name="header">
                                <h:outputText value="ID" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.id}" />
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.stakeholder.corpName}" filterBy="#{ULPItemApplication.stakeholder.corpName}">
                            <f:facet name="header">
                                <h:outputText value="Company name" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.stakeholder.corpName}" />
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.name}" filterBy="#{ULPItemApplication.name}">
                            <f:facet name="header">
                                <h:outputText value="Name" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.name}" />
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Image" />
                            </f:facet>
                            <p:graphicImage id="imageDisplay" value="/images/upload/media/#{ULPItemApplication.imageURL}"
                                            height="50" width="70"/> 
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.costOfItem}" filterBy="#{ULPItemApplication.costOfItem}">
                            <f:facet name="header">
                                <h:outputText value="Cost Of Item" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.costOfItem} SGD" />
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.maxQuantity}" filterBy="#{ULPItemApplication.maxQuantity}">
                            <f:facet name="header">
                                <h:outputText value="Maximum Quantity" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.maxQuantity}" />
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.validFrom}" filterBy="#{ULPItemApplication.validFrom}">
                            <f:facet name="header">
                                <h:outputText value="Valid From" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.validFrom}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.validUntil}" filterBy="#{ULPItemApplication.validUntil}">
                            <f:facet name="header">
                                <h:outputText value="Valid Until" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.validUntil}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{ULPItemApplication.status}" filterBy="#{ULPItemApplication.status}">
                            <f:facet name="header">
                                <h:outputText value="Status" />
                            </f:facet>
                            <h:outputText value="#{ULPItemApplication.status}" />
                        </p:column>
                    </p:dataTable>
                </p:tab> 
            </p:accordionPanel> 
        </p:panel>
    </ui:define>
</ui:composition>